package com.kayt.cyberBar.cpublic.business.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kayt.cyberBar.common.PageData;
import com.kayt.cyberBar.common.ServerResponse;
import com.kayt.cyberBar.cpublic.business.entity.po.CPublicKey;
import com.kayt.cyberBar.cpublic.business.entity.vo.PublicKeyVO;
import com.kayt.cyberBar.cpublic.business.entity.vo.PublicQueryVO;
import com.kayt.cyberBar.cpublic.business.server.IPublicKeyServer;
import com.kayt.cyberBar.cpublic.business.service.IPublicKeyService;

@Service("iPublicKeyService")
public class PublicKeyServiceImpl implements IPublicKeyService {
	
	@Autowired
	private IPublicKeyServer iPublicKeyServer;
	
	@Override
	public ServerResponse<PageData<PublicKeyVO>> getKeyList (PublicQueryVO query) {
		PageData<CPublicKey> pageData = this.iPublicKeyServer.get_key_list(query);
		return this.iPublicKeyServer.assemble_result_list(pageData);
	}

	@Override
	public ServerResponse<PublicKeyVO> getKey (PublicKeyVO vo) {
		CPublicKey fair = this.iPublicKeyServer.get_key(vo);
		return this.iPublicKeyServer.assemble_result(fair);
	}
	
	@Override
	public ServerResponse<PublicKeyVO> addKey () {
		CPublicKey fair = this.iPublicKeyServer.add_key();
		return this.iPublicKeyServer.assemble_result(fair);
	}
	
	@Override
	public ServerResponse<String> updateKey (PublicKeyVO vo) {
		int result = this.iPublicKeyServer.update_key(vo);
		return this.iPublicKeyServer.assemble_result_string(result);
	}
}
